#!/bin/bash

# 检查nftables是否安装
if command -v rpm >/dev/null 2>&1; then
    # CentOS/RHEL/Fedora系统
    if ! rpm -q nftables &>/dev/null; then
        echo "[-] nftables未安装"
        exit 1
    fi
elif command -v dpkg >/dev/null 2>&1; then
    # Debian/Ubuntu系统
    if ! dpkg -l | grep '^ii' | grep -qw nftables; then
        echo "[-] nftables未安装"
        exit 1
    fi
else
    echo "[-] 无法确定包管理器类型"
    exit 1
fi

# 检查nftables服务状态
if ! systemctl is-active nftables &>/dev/null; then
    echo "[-] nftables服务未运行"
    exit 1
fi

echo "[+] nftables已安装并运行"
exit 0
